window.onload = function(){
	var obj = document.getElementById("wrap");
	obj.onmouseover = function(){
		startMove(10,0,100);
	}
	obj.onmouseout = function(){
		startMove(-10,-160,0);
	}
}

var alpha = 30;
var timer = null;
function startMove(speed_a,final_x,final_alpha){
	clearInterval(timer);
	var obj = document.getElementById("wrap");
	var speed = 0;
	timer = setInterval(function(){
		if(obj.offsetLeft == final_x){
			clearInterval(timer);
		}else{
			speed = (final_x - obj.offsetLeft)/10;    //缓冲动画
			// if(speed > 0){                         //判断speed正负，向上或向下取整保证最终位置正确
			// 	speed = Math.ceil(speed);
			// }else{
			// 	speed = Math.floor(speed);
			// }
			speed = speed > 0 ? Math.ceil(speed):Math.floor(speed);   //if判断的简写
			obj.style.left = obj.offsetLeft + speed + "px";   
			// alpha += speed_a;                      //改变透明度
			// obj.style.filter = 'alpha(opacity:'+alpha+')';
			// obj.style.opacity = alpha/100;
		}
			},30)
}

